package com.y.architecture.polliing;

/**
 * Created by youjingjing on 2017/12/12.
 */

class PollingManager {
//    private HashMap<String, SubjectModel<EventInterface>> activeSubjectMap;

    private static PollingManager manager;


//    private PollingManager() {
//        activeSubjectMap = new HashMap<>();
//    }
//
    public static PollingManager getInstance() {
        if (null == manager) {
            synchronized (PollingManager.class) {
                if (null == manager) {
                    manager = new PollingManager();
                }
            }
        }

        return manager;
    }
//    public ObservableTransformer<Long, Long> composeEvent(final String tag, final EventInterface outEvent) {
//
//        BehaviorSubject<EventInterface> subject = getSubject(tag);
//        if (null == subject) {
//            Timber.tag(Constants.TAG).e("subject = null");
//            return new EmptyObservableTransformer();
//        }
//
//        final Observable observable = subject.filter(new Predicate<EventInterface>() {
//            @Override
//            public boolean test(EventInterface event) throws Exception {
//                Timber.tag(Constants.TAG).i("receive event: %s", event);
//                boolean filter = outEvent == event || event == ALL;
//                if (filter) clearSubject(tag);
//                return filter;
//            }
//        });
//
//        return new ObservableTransformer<Long, Long>() {
//            @Override
//            public ObservableSource<Long> apply(Observable<Long> upstream) {
//                return upstream.subscribeOn(Schedulers.io()).takeUntil(observable);
//            }
//        };
//    }
//    //Subject
//    private BehaviorSubject<T> behaviorSubject;
//
//    //订阅关系
//    private Disposable disposable;
//
//    //轮询器
//    private PollingRequest pollingRequest;
//
//    public void clearSubject(){
//        if (null == disposable || disposable.isDisposed()) return;
//
//        disposable.dispose();
//    }

}
